package controle;

import presentation.PSabot;
import solitaire.application.Carte;
import solitaire.application.Sabot;
import solitaire.application.Tas;

public class CSabot extends Sabot implements ICTas {
	protected PSabot presentation;
	
	public CSabot(String nom, CUsine usine) {
		super(nom, usine);
		presentation=new PSabot(this);
	}

	public PSabot getPresentation() {
		return presentation;
	}

	public void setPresentation(PSabot presentation) {
		this.presentation = presentation;
	}

	@Override
	public void depiler() {
		try {
			presentation.depiler();
			super.depiler();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Override
	public void retournerCarte() throws Exception {
		presentation.retournerCarte();
		super.retournerCarte();
	}

	@Override
	public void retourner() throws Exception {
		presentation.retourner();
		super.retourner();
	}

	public void empiler(ICCarte carte) {
			presentation.empiler(carte.getPresentation());
	}

	public boolean isEmpilable(ICCarte carte) {
		return isEmpilable((Carte) carte);
	}

	public boolean isEmpilable(ICTas tas) {
		return isEmpilable((Tas)tas);
	}

	public boolean isEmpilable(ICTas tas, int nbCartes) {
		return isEmpilable((Tas)tas, nbCartes);
	}
	
	public void setReserve(Tas arg0) {
		super.setReserve(arg0);
		presentation.setReserve(this.getCachees());
	}

	public ICTas getCachees(){
		return (ICTas) this.cachees;
	}
	
	public ICTas getVisibles(){
		return (ICTas) this.visibles;
	}

}
